package com.example.lc.myinternationalizationdemo;

import android.content.Intent;
import android.os.Bundle;
import android.os.Process;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

/**
 * 国际化遇到的坑 网上找到额国家代码缩写都是错的折腾了半天郁闷死. http://dditblog.com/blog_436.html
 */
public class MainActivityTwo extends AppCompatActivity implements View.OnClickListener {


    private Button btn_select_ml;
    private Button btn_select_el;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_two);
        initView();

    }

    private void initView() {
        btn_select_ml = (Button) findViewById(R.id.btn_select_ml);
        btn_select_ml.setOnClickListener(this);
        btn_select_el = (Button) findViewById(R.id.btn_select_el);
        btn_select_el.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_select_ml:
                LocaleUtils.updateLocale(this, LocaleUtils.LOCALE_MELAYU);
                Intent intent = new Intent(this, MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                overridePendingTransition(0, 0);
                // 杀掉进程
                Process.killProcess(Process.myPid());
                System.exit(0);
                break;
            case R.id.btn_select_el:
                LocaleUtils.updateLocale(this, LocaleUtils.LOCALE_ENGLISH);
                Intent intent2 = new Intent(this, MainActivity.class);
                intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent2);
                overridePendingTransition(0, 0);
                // 杀掉进程
                Process.killProcess(Process.myPid());
                System.exit(0);
                break;
        }
    }
}
